Similar to Microsoft SQL Server, Derby supports IDENTITY columns to help you creating auto-incremented sequence values for primary key columns. Derby offers two variations of IDENTITY columns:
我们将通过上述方法增加自增Column.
CREATE TABLE EMPLOYEE (
employee_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 100, INCREMENT BY 1),
name CHAR(90) NOT NULL,
CONSTRAINT EMPLOYEE_PK PRIMARY KEY (employee_ID))
因为Derby不支持通过Alert创建IDENTITY列,
Error: ALTER TABLE statement cannot add an IDENTITY column to a table.
目前在下尚未发现除了重建table之外的有效方法.
参考链接:
1:Tables with Primary Key Column “GENERATED … AS IDENTITY”
2. Create AutoIncrement column/field in Apache Derby
3. Derby PK auto-increment woes
Derby : Create/Rename/Drop Index <->
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.